package com.briup.ch08;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @Author briup-adam
 * @Date 2023/10/16 上午11:16
 * @Description
 **/

public class CollectionsDemo {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 4, 6, 241, 514, 52, 3, 41, 11);
        //找最大
        Integer max = Collections.max(list);
        Integer min = Collections.min(list);
        System.out.println("max = " + max);
        System.out.println("min = " + min);
        //排序
        Collections.sort(list);
        System.out.println(list);
        //反转
        Collections.reverse(list);
        System.out.println(list);
        //排序
        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1%2==1?-1:1;
            }
        });
        System.out.println(list);
        Collections.shuffle(list);
        System.out.println(list);
    }

}
